﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using ZeroSum.DependencyInjection.Attributes;
using ZeroSum.DependencyInjection.Extensions;
using ZeroSum.DependencyInjection.Interfaces;
using ZeroSum.IdGenerator;
using ZeroSum.IdGenerator.Configurations;
using ZeroSum.IdGenerator.Constants;

namespace ZeroSum;

/// <summary>
///     Domain层初始化注册，要早于AspNetCore层
/// </summary>
[StartupOrder(1001)]
public class Startup : IAppStartup
{
    public void ConfigurationServices(IServiceCollection services, IConfiguration configuration)
    {
        services.AddDependencyInjection();
    }
    public void AddIDGenerate(IServiceCollection services, IConfiguration configuration)
    {
        var options = configuration.GetSection(IdGeneratorConst.IdGeneratorOptions).Get<IdGeneratorOptions>();
        if (options?.Enabled == true)
            IDGenerator.SetIdGenerator(options);
    }
}